﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.effects {
    import Engine.Classes.*;
    import flash.display.*;
    import Classes.*;
    import flash.filters.*;

    public class FireworksEffect extends AnimationEffect {

        public function FireworksEffect(_arg1:MapResource, _arg2:String, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=false){
            this.m_effectName = _arg2;
            this.m_isAutoUpdating = _arg3;
            this.m_isLooping = _arg4;
            this.m_lastFrame = -1;
            this.m_isActive = true;
            this.m_isCentering = _arg5;
            super(_arg1, _arg2, _arg3, _arg4, _arg5);
        }
        override public function reattach():void{
            var _local2:AnimatedBitmap;
            var _local3:Array;
            var _local4:Array;
            var _local5:Array;
            var _local6:Array;
            if (((!(m_itemImage)) || (!(m_itemImage.getInstance())))){
                return;
            };
            if (!m_effectImage){
                m_effectImage = (m_itemImage.getInstance().image as DisplayObject);
                _local2 = (m_effectImage as AnimatedBitmap);
                _local2.height = (_local2.height * (0.5 * Math.random()));
                _local2.width = (_local2.width * Math.random());
                _local3 = [[0.9, 0.8, 0.3], [0.7, 0.1, 0.1], [0.6, 0.1, 0.5], [0.9, 0.2, 0.9], [0.3, 0.9, 0.2], [0.5, 0.2, 0.7], [0.9, 0.2, 0.4], [0.9, 0.6, 0.8], [0.7, 0.9, 0.5], [0.7, 0.3, 0.9], [0.5, 0.9, 0.9], [0.8, 0.9, 0.2], [0.8, 0.9, 0.2], [0.9, 0.8, 0.1]];
                _local4 = _local3[Math.floor((Math.random() * _local3.length))];
                _local5 = new Array();
                _local5[0] = _local4[0];
                _local5[6] = _local4[1];
                _local5[12] = _local4[2];
                _local5[18] = 1;
                _local6 = [new ColorMatrixFilter(_local5)];
                _local2.filters = _local6;
            };
            m_effectImage.x = ((-((m_effectImage.width >> 1)) + m_itemImage.offsetX) + x);
            m_effectImage.y = (((-((m_effectImage.height >> 1)) + m_itemImage.offsetY) + y) - 130);
            var _local1:Sprite = getAttachParent();
            if (_local1){
                _local1.addChild(m_effectImage);
            };
            if (!_local2){
                m_isActive = false;
            };
        }
        override public function animate(_arg1:uint):Boolean{
            var _local2:AnimatedBitmap;
            var _local3:DisplayObject;
            var _local4:Number;
            var _local5:Boolean;
            if (!m_isActive){
                return (m_isActive);
            };
            if (!m_itemImage){
                loadAnimationEffect();
            };
            if (m_effectImage){
                _local2 = (m_effectImage as AnimatedBitmap);
                _local3 = (m_mapResource.content as DisplayObject);
                if (_local2){
                    if (m_isAutoUpdating){
                        _local4 = (1 / m_originalFPS);
                        updateAnimatedBitmap(_local4);
                    };
                    if (!_local2.isPlaying){
                        _local2.reset();
                    };
                    if (!m_isLooping){
                        _local5 = (((_local2.currentFrame < m_lastFrame)) || ((_local2.currentFrame == (_local2.numFrames - 1))));
                        if (((_local2.isPlaying) && (_local5))){
                            _local2.stop();
                            this.cleanUp();
                            _local3.visible = true;
                            m_isActive = false;
                        } else {
                            m_lastFrame = _local2.currentFrame;
                        };
                    };
                } else {
                    m_isActive = false;
                };
            };
            return (m_isActive);
        }

    }
}//package Classes.effects 
